<?php
require('../../../lib/base.php');
$base=new base('web');
$session=$base->library('session',array('build'=>false));
if(!$session->ISSESS()){
	header('Location: '.domain.'view/Login.php?back='.domain.'home/index.php');
}else{
	$data['menu']=$base->cache(array('tag'=>'web.header','time'=>86400));
	$data['menu']=unserialize($data['menu']);
	$data['foot']=$base->cache(array('tag'=>'web.footer','time'=>86400));
	$cache=$base->cache(array('tag'=>'web.home.menu','time'=>86400));
	if($cache===false){
		$sort=$base->model('sort');
		$data['HomeMenu']=$sort->SortTree(array('where'=>array('label ='=>'HomeMenu','locked='=>0),'order'=>array('sequence'=>'desc')));
		$base->cache(array('content'=>serialize($data['HomeMenu']),'tag'=>'web.home.menu','time'=>86400));
	}else{
		$data['HomeMenu']=unserialize($cache);
	}
	$content=$base->model('content');
	$pams=array('order'=>array('sequence'=>'DESC','date'=>'DESC'),'limit'=>array(intval($base->get('start')),15));
	$data['total']=$content->GContent(array('select'=>'COUNT(*) AS count','where'=>$pams['where']));
	$data['total']=empty($data['total'])?0:$data['total'][0]['count'];
	$data['publish']=$content->GContent($pams);
	$pagination=$base->library('pagination',array('base_url'=>domain.'view/publish.php?','total_rows'=>$data['total'],'per_page'=>15,'first_link'=>'首页','last_link'=>'末页','cur_tag_open'=>'<a href="#" class="active">','cur_tag_close'=>'</a>'));
	$data['mail']=$session->GVAR('mail');
	$data['pagination']=$pagination->create_links();
	$data['commision']=$session->GVAR('commision');
	$data['bank']=$session->GVAR('bank');
	$data['ip']=long2ip($session->GVAR('ip'));
	$data['date']=date('Y-m-d H:i:s',$session->GVAR('date'));
	$data['money']=$session->GVAR('money');
	$data['frozen']=$session->GVAR('frozen');
	$base->set($data);
	$base->view('home/index.php');
}
?>